package com.liang.config;

import com.liang.service.CBlogService;
import lombok.AllArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @name: MySchedule
 * @author: 李昂
 * @date: 2021-01-22 20:03
 * @description：MySchedule 定时任务每天中午12点
 * 将blog历史查看，点赞，评论数据存储起来
 * 只存储7日的数据七日后便删除数据
 * @update: 2021-01-22 20:03
 */
@Component
@AllArgsConstructor
public class MySchedule {

    private CBlogService blogService;

    @Scheduled(cron = "0 0 12 * * ?", zone = "Asia/Shanghai")
    public void cron() {
        //备份历史blog数据
        blogService.produceBlog();
        //删除超出七天的历史数据
        blogService.deleteProduce();
    }
}
